<!-- $Id: show.php,v 1.1 2011-06-17 04:43:20 herve Exp $ -->

<h2>View role <?php echo $model->name; ?></h2>
<?php
$this->widget('application.widgets.SubMenu', array (
"items" => array (
	'list',
	'create',
	'changePwd',
	'update',
	'delete',
	'admin'
	)
	));
?>


<table class="dataGrid">
	<tr>
		<th class="label"><?php echo CHtml::encode(Yii::t('user', 'name')); ?>
		</th>
		<td><?php echo CHtml::encode($model->name); ?></td>
	</tr>
	<tr>
		<th class="label"><?php echo CHtml::encode(Yii::t('user', 'description')); ?>
		</th>
		<td><?php echo CHtml::encode($model->description); ?></td>
	</tr>
	<tr>
		<th class="label"><?php echo CHtml::encode(Yii::t('user', 'operations')); ?>
		</th>
		<td>
			<ul style="border: 0px; padding-top: 0px; margin-top: 0px">
			<?php
			$tasks = $model->getChildren();
			$allTasks = array();

			foreach ($tasks as $tmp)
			{
				$arr = split("\.", $tmp->name);
				if (! isset ($allTasks[$arr[0]]))
				{
					$allTasks[$arr[0]] = array();
				}
				$allTasks[$arr[0]][] = $tmp;
			}

			foreach ($allTasks as $r => $tasks)
			{
				echo "<li>$r<ul>";

				foreach ($tasks as $task)
				{
					echo "<li>" . CHtml::encode($task->description) . "</li>";
					$operations = $task->getChildren();

					if (isset($operations) && count($operations) > 0)
					{
						foreach ($operations as $operation)
						{
							echo "<li>" . Chtml::encode($operation->description) . "</li>";
						}
					}
				}
				echo "</ul></li>";
			}

			?>
			</ul>
		</td>
	</tr>
</table>
